﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CSharp.Libs.Koc;
using System.Collections;

namespace CSharp.Libs.WPF.UserControls
{
    /// <summary>
    /// Interaktionslogik für UserControl1.xaml
    /// </summary>
    public partial class AllianceList : UserControl
    {
        #region declarations
        private Kernel _KRNL = null;
        private AllianceMapViewViewModel _AMVVM = null;
        #endregion



        #region constructor destructor
        public AllianceList()
        {
            InitializeComponent();
        }
        #endregion



        #region event handling
        private void mnuAddAllianceToCompareList_Click(object sender, RoutedEventArgs e)
        {
            if (lvAllyList.SelectedItems.Count > 0)
            {
                foreach (KocAllianceListItem KALI in lvAllyList.SelectedItems)
                {
                    Int32 idxColor = 0;
                    Boolean Exists = false;

                    foreach (KocAllianceListItem kaliSeek in _AMVVM.AllianceCompareList)
                    {
                        idxColor++;

                        if (kaliSeek.AllianceId == KALI.AllianceId)
                        {
                            Exists = true;
                            break;
                        }
                    }

                    if (!Exists)
                    {
                        KALI.Color = _AMVVM.GetDefaultColor(idxColor);
                        _AMVVM.AllianceCompareList.Add(KALI);
                    }
                }
            }
        }
        #endregion



        #region private functions
        private void _Initialize(
            Kernel KRNL)
        {
            _KRNL = KRNL;
            _AMVVM = new AllianceMapViewViewModel(_KRNL);
            DataContext = _AMVVM;
        }
        #endregion



        #region interface
        #region properties
        public AllianceMapViewViewModel AMVVM
        {
            get
            {
                return _AMVVM;
            }
        }
        #endregion

        #region methods
        public void Initialize(
            Kernel KRNL)
        {
            _Initialize(KRNL);
        }
        #endregion
        #endregion
    }
}
